function EEG = cvc_timecut(EEG,cutfile)
% CVC_TIMECUT
%
%  Synopsis
%  ========
%
%  EEG = cvc_timecut(EEG,cutfile)
%
%  -- Author: Mads Dyrholm --
%     Center for Visual Cognition, University of Copenhagen.
%     2010 - November 2011
%
%  Purpose
%  =======
%
%  Inputs
%  ======
%
%  cutfile - example, seconds
%
%    10
%    20    30
%    60    70
%   300
%
%  Note that first and last lines are mandatory.

[q,w] = textread(cutfile,'%f%f');
A = [q,w]
if length(w)<length(q), w=cat(1,w,0); end
A = A*EEG.srate;
[dummy,idxx] = sort(A(:,1));
A = A(idxx,:);
if size(A,1)>=2 && A(1,2)==0 && A(end,2)==0 && max(A(:))<EEG.pnts
  fprintf('CVC_TIMECUT: cutfile is valid, consider it done.\n');
  if A(1,1)>=1
    A(1,:) = [1 A(1,1)];
  else
    A(1,:) = []; 
  end
  A(end,2) = EEG.pnts;  
  EEG = eeg_eegrej( EEG, A);
else
  error('CVC_TIMECUT: cutfile is invalid.');
end
